package com.lyz.dataStructure.dome.CollectionDemo;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 21:00
 * @Description:
 **/

import java.util.ArrayList;
import java.util.List;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/8/25 21:00
 *@Description:
 **/
public class ArrayListDemo2 {
    public static void main(String[] args) {
        List al = new ArrayList();
        al.add("a1");
        al.add("a2");
        al.add("a3");
        al.add("a4");
        al.add("a2");
        System.out.println(al);
        System.out.println(al.get(2));
        al.add(2,"b1");
        System.out.println(al);
        System.out.println(al.get(2));
        System.out.println(al.indexOf("a2"));
        System.out.println(al.lastIndexOf("a2"));
        System.out.println(al);
        System.out.println(al.remove("a2"));
        System.out.println(al);
        List list = al.subList(2,4);//获取指定元素
        System.out.println(list);
    }
}
